<template>
	<view class="goods_detail">
		<swiper indicator-dots>
			<swiper-item v-for="(item,index) in swiper" :key='index'>
				<image :src="item.src" mode=""></image>
			</swiper-item>
		</swiper>
		<view class="box1">
			<view class="price">
				<text>${{list.sell_price}}</text>
				<text>${{list.market_price}}</text>
			</view>
			<view class="jieshao">
				{{list.title}}
			</view>
			
		</view>
		<view class="line">
			
		</view>
		<view class="box2">
			<view>货号:{{list.goods_no}}</view>
			<view>货号:{{list.stock_quantity}}</view>
		</view>
		<view class="line">
			
		</view>
		
		<view class="box3">
			<view class="xaingqing">
				详情介绍：
			</view>
			<view class="concent">
			<rich-text :nodes="concent"></rich-text>
			</view>
		</view>
		<!-- 	引入像淘宝一样的组件 -->
		<view class="goods_taoba">
			<uni-goods-nav :fill="true"  :options="options" :buttonGroup="buttonGroup"  @click="onClick" @buttonClick="buttonClick" />
		</view>
		
	</view>
</template>

<script>
	import uniGoodsNav from '../../uni_modules/uni-goods-nav/components/uni-goods-nav/uni-goods-nav.vue'
	export default {
		
		data() {
			return {
				id:0,
				swiper:[],
				list:{},
				concent:'',
				 options: [{
				            icon: 'headphones',
				            text: '客服'
				        }, {
				            icon: 'shop',
				            text: '店铺',
				            info: 3,
				            infoBackgroundColor:'#007aff',
				            infoColor:"red"
				        }, {
				            icon: 'cart',
				            text: '购物车',
				            info: ''
				        }],
				        buttonGroup: [{
				          text: '加入购物车',
				          backgroundColor: '#ff0000',
				          color: '#fff'
				        },
				        {
				          text: '立即购买',
				          backgroundColor: '#ffa200',
				          color: '#fff'
				        }
				        ]
			}
		},
		methods: {
			async getSwiper(){
				const res =await this.$myRequest({
					url:'/api/getthumimages/' + this.id
				})
				console.log(res)
				this.swiper= res.data.message 
			},
			async getcanshu(){
				const res =await this.$myRequest({
					url:'/api/goods/getinfo/'+this.id
				})
				this.list = res.data.message[0]
			},
			async getneirong(){
				const res =await this.$myRequest({
					url:'/api/goods/getdesc/'+this.id
				})
				console.log(res)
				this.concent = res.data.message[0].content
			},
			/* 引入的组件的方法 */
			  onClick (e) {
			        uni.showToast({
			          title: `点击${e.content.text}`,
			          icon: 'none'
			        })
			      },
			      buttonClick (e) {
			        console.log(e)
			        this.options[2].info++
			      }
			    
				
		},
		onLoad(options){
			console.log(options)
			this.id= options.id
			this.getSwiper()
			this.getcanshu()
			this.getneirong()
		},
		components: {uniGoodsNav} /* 注册uniGoodsNav*/
	}
</script>

<style lang="scss"> 
	.goods_detail{
		width: 100%;
		height: 700rpx;
		swiper{
			width: 100%;
			height: 100%;
	},
	.box1{
		page{
			margin:0rpx;
			padding:0rpx
		}
		padding: 10rpx;
		.price{
			color: #B50E03;
			font-size: 30rpx;
			line-height: 80rpx;
			text:nth-child(2){
				color: #C0C0C0;				font-size: 27rpx;
				text-decoration: line-through;
				padding-left: 25rpx;
			}
		}
		.jieshao{
			font-size: 28rpx;
			line-height: 60rpx;
		}
		
	
	}
	.line{
			height: 13rpx;
			width: 750rpx;
			background-color: #eee;
		
		
	}
	.box2{
		line-height: 70rpx;
		font-size: 28rpx;
		
	}
	.box3{
		padding-bottom: 50rpx;
		.xaingqing{
			font-size: 32rpx;
			padding-left: 10rpx;
			line-height: 78rpx;
			border-bottom: 1px solid #eee;
			
		}
		.concent{
			padding-top: 10rpx;
			font-size: 25rpx;
			line-height: 50rpx;
		}
	}
	.goods_taoba{
		position: fixed;
		bottom: 0;
		width: 100%;
	} 
	}
</style>
